using namespace std;


#include <iostream>
#include "DoubleLinkedList.h"

template <typename DT>
typename DoubleLinkedList<DT>::iterator
find(DoubleLinkedList<DT>& _list, DT&  _val){
        if( _list.empty())
                return _list.end();
        else{
                 for(typename DoubleLinkedList<DT>::iterator p = _list.begin(); p !=  _list.end(); ++p ){
                        if ( *p  == _val){
                                return p;
                        }
                }

        }
        return _list.end();
}

template <typename DT>
void printlist(const DoubleLinkedList<DT> &L ){
        if(L.empty())
                cout << "(empty)";
        else{
                auto itr = begin( L );
                cout << "[ " << *itr++;
                while( itr != end( L ) )
                        cout << "," << *itr++;
                cout << " ]" << endl;
        }
}


int main(int argc, char *argv[]){
	DoubleLinkedList<int> L;
	for( int i = 1; i < 6; i ++ ){
		L.push_back(i);
	}
	printlist( L );

	DoubleLinkedList<int>::iterator iter;
	int x = 3;
	iter = find(L, x);
	L.erase(iter);
	printlist( L );

	iter = find(L, x);	
	return 0;
}




